package com.eb.service;

import com.eb.dao.KjDao;
import com.eb.mapper.BargainGoodsMapper;
import com.eb.pojo.BargainGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class KjService {

    @Autowired
    private KjDao kjDao;
    @Autowired
    private BargainGoodsMapper bargainGoodsMapper;


    public Page<Map<String, Object>> list(String name, int page, int size) {
        return kjDao.list("%"+name+"%",PageRequest.of(page-1,size));
    }

    public void add(BargainGoods bargainGoods) {
        bargainGoodsMapper.insert(bargainGoods);
    }

    public void delete(long id) {
        bargainGoodsMapper.deleteByPrimaryKey(id);
    }
}
